﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace Draglets.UI
{
    [ToolboxData("<{0}:ButtonDemo runat=server></{0}:ButtonDemo>")]
    public class ButtonDemo : WebControl
    {
        protected override void OnLoad(EventArgs e)
        {
            StringBuilder scriptString = new StringBuilder();
            scriptString = new StringBuilder();
            scriptString.Append("<meta charset=\"UTF-8\" />");
            scriptString.Append("<script type=\"text/javascript\">");
            scriptString.Append("$(function() {");
            scriptString.Append("$(\".demo button:first\").button({");
            scriptString.Append("icons: {");
            scriptString.Append("primary: 'ui-icon-locked'");
            scriptString.Append("},");
            scriptString.Append("text: false");
            scriptString.Append("}).next().button({");
            scriptString.Append("icons: {");
            scriptString.Append("primary: 'ui-icon-locked'");
            scriptString.Append("}");
            scriptString.Append("}).next().button({");
            scriptString.Append("icons: {");
            scriptString.Append("primary: 'ui-icon-gear',");
            scriptString.Append("secondary: 'ui-icon-triangle-1-s'");
            scriptString.Append("}");
            scriptString.Append("}).next().button({");
            scriptString.Append("icons: {");
            scriptString.Append("primary: 'ui-icon-gear',");
            scriptString.Append("secondary: 'ui-icon-triangle-1-s'");
            scriptString.Append("},");
            scriptString.Append("text: false");
            scriptString.Append("});");
            scriptString.Append("});");
            scriptString.Append("</script>");
            scriptString.Append("<style>");
            scriptString.Append("</style>");
            scriptString.Append("<div class=\"demo\">");
            scriptString.Append("<button>Button1</button>");
            scriptString.Append("<button>Button2</button>");
            scriptString.Append("<button>Button3</button>");
            scriptString.Append("<button>Button4</button>");
            scriptString.Append("</div><!-- End demo -->");
            scriptString.Append("<div class=\"demo-description\">");
            scriptString.Append("<p>Some buttons with various combinations of text and icons, here specified via metadata.</p>");
            scriptString.Append("</div><!-- End demo-description -->");
            LiteralControl addScript = new LiteralControl(scriptString.ToString());

            this.Controls.Add(addScript);
            
            base.OnLoad(e);
        }
    }
}
